<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
</head>
<link href="${ctx}/css/main/base.css" rel="stylesheet" type="text/css" />
<link href="${ctx}/css/main/main.css" rel="stylesheet" type="text/css" />
<script src="scripts/inframe.js"></script>
<body>
<div id="info"><font color="red">${info}</font></div>
<form action="menu_modify.action" method="post">
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tab_m">
  <tr>
    <td colspan="2" class="zctop"><span class="font14 zc_bt">修改菜单主分类</span></td>
    </tr>
  <tr>
    <td class="w1">菜单编号：</td>
    <input type="hidden" name="menuCode" value="${sysMenu.menuCode}"/>
    <td class="w2 left"><input type="text" name="sysMenu.menuCode"  value="${sysMenu.menuCode}"/> 编号请尽量间隔开，2位数字<div id="errCode"></div></td>
  </tr>
  <tr>
    <td class="w1">菜单名称：</td>
    <td class="w2 left"><input type="text" name="sysMenu.menuName" value="${sysMenu.menuName}"/><div id="errName"></div></td>
  </tr>
  <tr>
    <td class="w1">菜单名称(英)：</td>
    <td class="w2 left"><input type="text" name="sysMenu.menuNameEn" value="${sysMenu.menuNameEn}" class="fl_l"/><div id="errNameEn"></div></td>
  </tr>
  <tr>
    <td class="w1">菜单图片：</td>
    <td class="w2 left"><input type="text" name="sysMenu.menuImage" value="${sysMenu.menuImage}"/><div id="errImage"></div></td>
  </tr>
  <tr>
    <td colspan="2" class="hei_1">
    <input type="hidden" name="sysMenu.menuId" value="${sysMenu.menuId}"/>
    <input type="button" onclick="modifyMenu();" value="确 定" class="log_f zc_b">
	<input type="button" onclick="returnMenu();" value="返 回" class="log_f zc_b">
    </td>
    </tr>
</table>
</form>
</body>
</html>
<script type="text/javascript" src="${ctx}/scripts/commons/validation.js"></script>
<script type="text/javascript">
	function modifyMenu(){
		var code = document.getElementById("sysMenu.menuCode").value ;
		var name = document.getElementById("sysMenu.menuName").value;
		var image = document.getElementById("sysMenu.menuImage").value;
		var nameEn = document.getElementById("sysMenu.menuNameEn").value;
	var flag1 = /^[0-9]{2}$/;
	if(!flag1.test(code)){
		document.getElementById("errCode").innerHTML = "<font color='red'>编号必须是两位数字</font>";
	   return false;
	}
	if(code.length > 2){
		document.getElementById("errCode").innerHTML = "<font color='red'>编号必须是两位数字</font>";
	   return false;
	}
	if(code.length == 0 && name.length == 0 && image.length == 0){
	   document.getElementById("errName").innerHTML = "<font color='red'>不能添加空的菜单节点</font>";
	   return false;
	}
	if(name == '' || name.length == 0){
	   document.getElementById("errName").innerHTML = "<font color='red'>菜单名称不能为空</font>";
	   return false;
	}
	if(nameEn == '' || nameEn.length == 0){
	   document.getElementById("errNameEn").innerHTML = "<font color='red'>菜单英文名称不能为空</font>";
	   return false;
	}
	if(name.length > 0 && hasSpecialChart(name)){
			document.getElementById("errName").innerHTML = "<font color='red'> 菜单名称不能有特殊字符!</font>";
			return false;
		}
	if(name.length > 50){
	   document.getElementById("errName").innerHTML = "<font color='red'>菜单名称不能超过50</font>";
	   return false;
	}
	if(nameEn.length > 0 && hasSpecialChart(nameEn)){
			document.getElementById("errNameEn").innerHTML = "<font color='red'> 菜单英文名称不能有特殊字符!</font>";
			return false;
		}
	if(nameEn.length > 50){
	   document.getElementById("errNameEn").innerHTML = "<font color='red'>菜单英文名称不能超过50</font>";
	   return false;
	}
	if(name.length > 0 && (code.length == 0 || image.length == 0)){
	   document.getElementById("errName").innerHTML = "<font color='red'>菜单编号和图片都不能为空</font>";
	   return false;
	}
	if(image.length > 50){
	   document.getElementById("errImage").innerHTML = "<font color='red'>图片名称不能超过50</font>";
	   return false;
	}
	 
	 document.forms[0].submit();
		 
	}
	
	function returnMenu(){
		document.getElementById("sysMenu.menuCode").value = "";
		document.getElementById("sysMenu.menuName").value = "";
		document.getElementById("sysMenu.menuImage").value = "";
		history.go(-1);
	}
</script>
